package cn.woochen.functionwidget.sample

import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentPagerAdapter
import android.support.v7.app.AppCompatActivity
import cn.woochen.functionwidget.R
import cn.woochen.functionwidget.sample.player.PlayerFragment
import kotlinx.android.synthetic.main.activity_sdk.*

/**
 *sdk演示类
 *@author woochen
 *@time 2019/4/23 14:16
 */
class SdkActivity : AppCompatActivity() {
    val titles = mutableListOf<String>("视频播放","其他")
    val fragments = mutableListOf<Fragment>()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_sdk)
        initView()
    }

    private fun initView() {
        fragments.add(PlayerFragment.newInstance())
        fragments.add(PlayerFragment.newInstance())
        for (index in 0 until fragments.size) tab.addTab(tab.newTab())
        vp.adapter = object : FragmentPagerAdapter(supportFragmentManager) {
            override fun getItem(position: Int): Fragment = fragments[position]

            override fun getCount(): Int = titles.size

            override fun getPageTitle(position: Int): CharSequence? = titles[position]
        }
        tab.setupWithViewPager(vp)
    }
}
